home *** CD-ROM | disk | FTP | other *** search
- BEGIN {
- DQ=sprintf("%c",34)
- terminal = ""
- #{{{}}}
- # {{{ init some arrays. for may work, even if no other values are stored
- term_data_conflict["-"]="-"
- alias["-"]="-"
- term_data_leader["-"]="-"
- # }}}
- # {{{ define unknown and/or not used terminals
- term_list["dumb"]="dumb"
- term_list["print"]="dumb"
- term_list["printer"]="dumb"
- term_list["printerbox"]="dumb"
- term_list["network"]="dumb"
- term_list["ansi"]="dumb"
- term_list["bussiplexer"]="dumb"
- term_list["arpanet"]="dumb"
- term_list["ethernet"]="dumb"
- term_list["patchboard"]="dumb"
- term_list["plugboard"]="dumb"
- term_list["switch"]="dumb"
- # }}}
- }
- #{{{ skip special terminals
- /^\(terminal \( *((sun)|(SUN)|(xterm)|(con80x25)|(console)) *\)/ {
- print("special terminal "$2" skipped, using predefined values")
- next
- }
- #}}}
- #{{{ start terminal
- /^\(terminal *\(.*\)$/ {
- terminal=substr($2,2,length($2)-2)
- if (term_list[terminal]!="") {
- current_term_data="@if-using ()\n"
- } else {
- current_term_data=""
- }
- current_conflict=""
- defined_alias=0
- # {{{ init used keys and aliases
- cntrl_h = 1
- # {{{ tab
- ok["tab"] = 1
- alias["tab"] = " (alias tab ( C-I ))"
- name["tab"] = "tab-key"
- # }}}
- # {{{ rubout
- ok["rubout"] = -1
- alias["rubout"] = "-"
- name["rubout"] = "del-key"
- # }}}
- # {{{ backspace
- ok["backspace"] = -1
- alias["backspace"] = "-"
- name["backspace"] = "backs-key"
- # }}}
- # {{{ clreol
- ok["clreol"] = -1
- alias["clreol"] = "-"
- name["clreol"] = "clreol-key"
- # }}}
- # {{{ delline
- ok["dellint"] = -1
- alias["delline"] = "-"
- name["delline"] = "delline-key"
- # }}}
- # {{{ begin
- ok["begin"] = -1
- alias["begin"] = "-"
- name["begin"] = "line-key"
- # }}}
- # {{{ end
- ok["end"] = -1
- alias["end"] = "-"
- name["end"] = "line-key"
- # }}}
- # {{{ move
- ok["move"] = -1
- alias["move"] = "-"
- name["move"] = "line-key"
- # }}}
- # {{{ copy
- ok["copy"] = -1
- alias["copy"] = "-"
- name["copy"] = "line-key"
- # }}}
- # {{{ exit
- ok["exit"] = -1
- alias["exit"] = "-"
- name["exit"] = "misc-key"
- # }}}
- # {{{ save
- ok["save"] = -1
- alias["save"] = "-"
- name["save"] = "misc-key"
- # }}}
- # {{{ replace
- ok["replace"] = -1
- alias["replace"] = "-"
- name["replace"] = "misc-key"
- # }}}
- # {{{ find
- ok["find"] = -1
- alias["find"] = "-"
- name["find"] = "misc-key"
- # }}}
- # {{{ suspend
- ok["suspend"] = -1
- alias["suspend"] = "-"
- name["suspend"] = "misc-key"
- # }}}
- # {{{ close
- ok["close"] = -1
- alias["close"] = "-"
- name["close"] = "misc-key"
- # }}}
- # {{{ open
- ok["open"] = -1
- alias["open"] = "-"
- name["open"] = "misc-key"
- # }}}
- # {{{ refresh
- ok["refresh"] = -1
- alias["refresh"] = "-"
- name["refresh"] = "misc-key"
- # }}}
- # {{{ insert-char
- ok["insert-char"] = -1
- alias["insert-char"] = "-"
- name["insert-char"] = "misc-key"
- # }}}
- # {{{ home
- ok["home"] = -1
- alias["home"] = "-"
- name["home"] = "home-key"
- # }}}
- # {{{ home-down
- ok["home-down"] = -1
- alias["home-down"] = "-"
- name["home-down"] = "home-key"
- # }}}
- # {{{ prev_page
- ok["prev_page"] = -1
- alias["pev_page"] = "-"
- name["prev_page"] = "page-key"
- # }}}
- # {{{ next_page
- ok["next_page"] = -1
- alias["prev_page"] = "-"
- name["next_page"] = "page-key"
- # }}}
- # {{{ up
- ok["up"] = -1
- alias["up"] = "-"
- name["up"] = "cursor-key"
- # }}}
- # {{{ down
- ok["down"] = -1
- alias["down"] = "-"
- name["down"] = "cursor-key"
- # }}}
- # {{{ left
- ok["left"] = -1
- alias["left"] = "-"
- name["left"] = "cursor-key"
- # }}}
- # {{{ right
- ok["right"] = -1
- alias["right"] = "-"
- name["right"] = "cursor-key"
- # }}}
- # {{{ help
- ok["help"] = -1
- alias["help"] = "-"
- name["help"] = "help-key"
- # }}}
- # {{{ f1
- ok["f1"] = -1
- alias["f1"] = "-"
- name["f1"] = "fx-key"
- # }}}
- # {{{ f2
- ok["f2"] = -1
- alias["f2"] = "-"
- name["f2"] = "fx-key"
- # }}}
- # {{{ f3
- ok["f3"] = -1
- alias["f3"] = "-"
- name["f3"] = "fx-key"
- # }}}
- # {{{ f4
- ok["f4"] = -1
- alias["f4"] = "-"
- name["f4"] = "fx-key"
- # }}}
- # {{{ f5
- ok["f5"] = -1
- alias["f5"] = "-"
- name["f5"] = "fx-key"
- # }}}
- # {{{ f6
- ok["f6"] = -1
- alias["f6"] = "-"
- name["f6"] = "fx-key"
- # }}}
- # {{{ f7
- ok["f7"] = -1
- alias["f7"] = "-"
- name["f7"] = "fx-key"
- # }}}
- # {{{ f8
- ok["f8"] = -1
- alias["f8"] = "-"
- name["f8"] = "fx-key"
- # }}}
- # {{{ f9
- ok["f9"] = -1
- alias["f9"] = "-"
- name["f9"] = "fx-key"
- # }}}
- # {{{ f10
- ok["f10"] = -1
- alias["f10"] = "-"
- name["f10"] = "fx-key"
- # }}}
- keys=" "
- use_keys=" "
- # }}}
- # {{{ init term data for this terminal
- current_term_data=current_term_data "@if-using ( term-alias )\n%s ( terminal ( %s )\n"
- # }}}
- }
- #}}}
- #{{{ end terminal
- /^\)$/ {
- if (terminal!="" && defined_alias) {
- # {{{ end aliases
- # {{{ get all aliases for current terminal
- for ( i in alias )
- if (alias[i]!="-")
- if (ok[i])
- current_term_data=current_term_data alias[i] "\n"
- # }}}
- # {{{ maybe add C-? as default rubout
- if (ok["rubout"]==-1) {
- alias["rubout"]=" (alias delete ( C-? ))"
- current_term_data=current_term_data alias["rubout"] "\n"
- ok["erubout"]=1
- name["erubout"]="esc-del-key"
- ok["erubout"]=1
- alias["erubout"]=""
- }
- # }}}
- # {{{ rubout defined, so define delete==rubout
- if (ok["rubout"]==1)
- current_term_data=current_term_data " (alias delete ( $rubout ))\n"
- # }}}
- # {{{ add fx-keys
- for (i=1;i<=10;i++)
- current_term_data=current_term_data" (alias f"i" ( C-[ "DQ"f "DQ (i%10)" ))\n"
- # }}}
- current_term_data=current_term_data " )\n"
- # }}}
- # {{{ used keys
- # {{{ mark keys as unhandled
- for ( i in alias )
- handled[name[i]]=""
- # }}}
- # {{{ get all use keys
- for ( i in alias ) {
- if (alias[i]!="-")
- if (ok[i])
- if (handled[name[i]]=="")
- { handled[name[i]]=1
- keys=keys name[i]" "
- use_keys=use_keys"use-"name[i]" "
- }
- alias[i]="-"
- }
- # }}}
- # {{{ maybe add C-H usage
- if (cntrl_h) {
- keys=keys"ctrl-h-key "
- use_keys=use_keys"use-ctrl-h-key "
- }
- # }}}
- # {{{ maybe add fx-handling
- if (handled[name["f1"]]=="") {
- keys=keys name["f1"]" "
- use_keys=use_keys"use-"name["f1"]" "
- }
- # }}}
- current_term_data=current_term_data " @use ( "keys")\n@fi\n@if-using ( "use_keys") %s @fi\n"
- # }}}
- # {{{ store usage of current term and name of terminal
- if (term_list[terminal]!="") {
- current_term_data=current_term_data "@fi\n"
- term_data_used[current_term_data]="un"
- print("ignoring "term_list[terminal]" terminal ("terminal").")
- } else {
- term_list[terminal]="duplicate"
- # {{{ add terminal name (leader or group)
- if (term_data_leader[current_term_data]!="")
- term_data_group[current_term_data]="" term_data_group[current_term_data] " " terminal
- else
- term_data_leader[current_term_data]=terminal
- # }}}
- # {{{ store conflicts for this term
- if (current_conflict!="")
- term_data_conflict[current_conflict]=term_data_conflict[current_conflict]" "terminal
- # }}}
- }
- # }}}
- count[current_term_data]++
- terminal=""
- }
- }
- #}}}
- #{{{ no terminal active, so skip line
- terminal=="" { next }
- #}}}
- #{{{ save alias
- /^ *\(alias/ {
- alias[$2]=" "$0
- }
- #}}}
- #{{{ check needed keys
- #{{{ init critical and handle
- { critical=0
- handle=0
- }
- #}}}
- #{{{ if used key, set handle to true
- $2~/^((rubout)|(backspace)|(up)|(down)|(left)|(right)|(f([123456789]|10)))$/ {
- handle=1
- }
- $2~/^(((prev)|(next))_page)|(home)|(home-down)|(clreol)|(delline)|(begin)|(end)$/ {
- handle=1
- }
- $2~/^(exit)|(save)|(refresh)|(open)|(close)|(suspend)|(find)|(replace)$/ {
- handle=1
- }
- #}}}
- #{{{ esc critical char -> critical
- $4=="C-[" && $5~/^"[abcdefghijklmnopqrstuvwxyz0123456789+\-%]$/ {
- if (handle)
- current_conflict=current_conflict " ;"$0" - "$5"\n"
- critical=1
- }
- #}}}
- #{{{ esc <> critical char -> critical
- $4=="C-[" && $5~/^"[<>{}]$/ && $6~/^(("[abp])|(\)\)))$/ {
- if (handle)
- current_conflict=current_conflict " ;"$0" - "$5"\n"
- critical=1
- }
- #}}}
- #{{{ not esc ... -> critical
- $4~/C-[^[H^]/ || ($2!="backspace" && $4=="C-H") {
- if (handle)
- current_conflict=current_conflict " ;"$0" - "$4"\n"
- critical=1
- }
- #}}}
- #{{{ handled sequence starting with C-H -> no cntrl_h usage or critical
- handle!=0 && critical==0 && $4=="C-H" {
- if ($2=="backspace")
- cntrl_h=0
- else
- critical=1
- }
- #}}}
- handle!=0 {
- if (ok[$2]==-1)
- ok[$2]=1
- if (ok[$2] && critical)
- ok[$2]=0
- if (ok[$2])
- defined_alias=1
- # {{{ maybe add esc-rubout
- if ($2=="rubout" && ok[$2]) {
- if ($4!="C-[") {
- ok["erubout"]=1
- alias["erubout"]=" ;esc-rubout can be used too"
- name["erubout"]="esc-del-key"
- }
- }
- # }}}
- }
- #}}}
- END {
- print("; This file is generated by make(1), defining local terminals") >"autoterm"
- for (i in term_data_leader)
- if (i!="-") {
- # {{{ print info for the group and collect names for terminal reference
- print("{{{ "count[i]" "term_data_used[i]"used:"term_data_leader[i] term_data_group[i]) >"autoterm"
- # {{{ gen termaliases
- if (term_data_group[i]!="") {
- termaliases=" ( termalias "term_data_leader[i]" ("term_data_group[i]" ) )\n"
- } else {
- termaliases=""
- }
- # }}}
- # {{{ print aliases and used keys
- printf(i,termaliases,term_data_leader[i],term_data_leader[i]) >"autoterm"
- # }}}
- print("}}}") >"autoterm"
- termlist=termlist"@ref-start-item "term_data_leader[i] term_data_group[i]"\n@ref-end-item\n"
- # }}}
- }
- # {{{ print conflicts
- print("{{{ conflicts") >"autoterm"
- for (i in term_data_conflict)
- if (i!="-")
- printf("{{{ %s\n%s}}}\n",term_data_conflict[i],i) >"autoterm"
- print("}}}") >"autoterm"
- # }}}
- # {{{ print terminal reference-file
- print("@{{{}}}") >"autoterm.r"
- print("@{{{ autoterm-r") >"autoterm.r"
- print("@{{{ which keyboards can be used") >"autoterm.r"
- # {{{ standard terminals
- print("This version works with (values for environment variables TERM or") >"autoterm.r"
- print("ORIGAMITERM):") >"autoterm.r"
- print("") >"autoterm.r"
- # {{{ xterm
- print("@if-using ( xterm )") >"autoterm.r"
- print("@if-using ( sun )") >"autoterm.r"
- print("@ref-start-item xterm") >"autoterm.r"
- print("If your keyboard/xterm is reconfigured to match a standard sun") >"autoterm.r"
- print("keyboard, you can also use ORIGAMITERM=SUN. Therefor you have to map") >"autoterm.r"
- print("the right keypad in the same way, a sun workstation does it.") >"autoterm.r"
- print("See in the bindings source file 'modeori-fun/terms' for the used") >"autoterm.r"
- print("keysequences.") >"autoterm.r"
- print("@fi") >"autoterm.r"
- print("@ref-end-item") >"autoterm.r"
- print("@if-using not( sun )") >"autoterm.r"
- print("@ref-start-item xterm") >"autoterm.r"
- print("@fi") >"autoterm.r"
- print("@ref-end-item") >"autoterm.r"
- print("@fi") >"autoterm.r"
- # }}}
- # {{{ sun
- print("@if-using ( sun )") >"autoterm.r"
- print("@ref-start-item sun") >"autoterm.r"
- print("@ref-end-item") >"autoterm.r"
- print("@fi") >"autoterm.r"
- # }}}
- # {{{ linux
- print("@if-using ( linux )") >"autoterm.r"
- print("@ref-start-item linux") >"autoterm.r"
- print("@ref-end-item") >"autoterm.r"
- print("@fi") >"autoterm.r"
- # }}}
- # {{{ collected terminals
- print(termlist) >"autoterm.r"
- # }}}
- print("Not all mentioned terminals support all keys. Use 'describe-bindings' for") >"autoterm.r"
- print("a complete list of command bindings for your terminal.") >"autoterm.r"
- # }}}
- print("@}}}") >"autoterm.r"
- print("@}}}") >"autoterm.r"
- # }}}
- }
-